<template>
	<div>
		<wanshi :phoneArr="phoneArr" :kai="kai"></wanshi>
	</div>
</template>

<script>
	import wanshi from '../../components/wanShiShangCheng.vue';
	export default {
		data(){
			return{
				phoneArr:[],
				pageindex:1,
				kai:false
			}
		},
		components:{
			"wanshi":wanshi
		},
		methods:{
			init(){
				uni.request({
					url:"http://localhost:8082/api/getgoods?pageindex="+this.pageindex,
					method:"GET",
					success: (data) => {
						console.log(data)
						if(this.pageindex==1){
							this.phoneArr=data.data.message
						}
						if(this.pageindex==2){
							this.phoneArr.push(...data.data.message)
						}
						if(data=[]){
							return this.kai=true
						}
					}
				})
			},
		},
		onPullDownRefresh() {
			this.pageindex=1
			this.kai=false
			uni.showToast({
				title: '加载中',
				duration: 2000
			});
			this.init()
		},
		onReachBottom() {
			this.pageindex++
			uni.showToast({
				title: this.pageindex==1||this.pageindex==2?'加载中':'没有数据了',
				duration: 2000
			});
			this.init()
		},
		onLoad(){
			this.init()
		}
	}
</script>

<style scoped>

</style>